package 双指针;

public class _003 {
    //202 快乐数
    public int panduan(int n){
        int sum=0;
        while(n>0){
            int t=n%10;
            sum+=t*t;
            n=n/10;
        }
        return sum;
    }

    public boolean isHappy(int n) {
        int slow=n,fast=panduan(n);
        while(slow!=fast){
            slow=panduan(slow);
            fast=panduan(panduan(fast));
        }
        return slow==1;
    }
}
